package org.baygo.view;

import org.baygo.view.api.FrameInterface;
import org.baygo.view.api.PanelInterface;
import org.baygo.view.api.impl.MyJPanelCreator;
import org.baygo.view.api.impl.MyJframeCreator;

import javax.swing.*;

public class MainFrame extends JFrame{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private static MainFrame frame;

	public static void openNewFrame(){
		if (frame == null){
			try {
				frame = new MainFrame();
				frame.init();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	private FrameInterface jframe = new MyJframeCreator();
	private PanelInterface panels = new MyJPanelCreator();
	
	public void init() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException{
//		UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
		
//		UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
//		UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
//		UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel");
		jframe.createFrame(panels.createHeaderPanel(),panels.createCenterPanel(),panels.createDownPanel(),"BabyGo!");
	}

	public static PanelInterface getPanel(){
		return frame.panels;
	}

	public static FrameInterface getJframe(){
		return frame.jframe;
	}

	public static MainFrame getMainFrame(){
		return frame;
	}
	
	public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
		MainFrame.openNewFrame();
	}

}